//
//  WYCAccountTool.m
//  初试
//
//  Created by 中企互联 on 2017/10/19.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCAccountTool.h"
#import "WYCAccount.h"
#import "MSAccuntLoginController.h"

#define AccountFile [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.data"]
@implementation WYCAccountTool

+(void)saveAccount:(WYCAccount *)account
{
    [NSKeyedArchiver archiveRootObject:account toFile:AccountFile];
}


+(WYCAccount *)account
{
    //取出账号
    WYCAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:AccountFile];
    return account;
}


+ (NSString *)unarchiveuid {
    
    return [self account].uid;
}

+ (NSString *)unarchiveuserName{
    
    return [self account].userName;
}

+ (NSString *)unarchiveavatarUrl{
    
    return [self account].avatarUrl;
}

+ (NSString *)unarchivephoneNumber{
    
    return [self account].phoneNumber;
}


+ (NSString *)unarchivebirthday{
    
    return [self account].birthday;
}

+ (NSString *)unarchivecreateTime{
    
    return [self account].createTime;
}

+ (NSString *)unarchivebelongBusid{
    
    return [self account].belongBusid;
}

+ (NSString *)unarchivebelongDepid{
    
    return [self account].belongDepid;
}

+ (NSString *)unarchivebelongRolid{
    
    return [self account].belongRolid;
}
+ (NSString *)unarchiveroleName{
     return [self account].roleName;
}

+ (NSString *)unarchivegender{
    return [self account].gender;
}
+ (NSString *)unarchiveheight{
    return [self account].height;
}
+ (NSString *)unarchivecountry{
    return [self account].country;
}
+ (NSString *)unarchiveprovince{
    return [self account].province;
}
+ (void)clearAccount {
    
    NSFileManager *manager = [NSFileManager defaultManager];
    
    [manager removeItemAtPath:AccountFile error:nil];
}

/**
 *  登陆工具
 */
+ (void)showLoginViewWith:(UIViewController *)object {
    
    [SVProgressHUD showErrorWithStatus:@"您以被迫下线，请重新登录！"];
    MSAccuntLoginController *loginVC = [[MSAccuntLoginController alloc] init];
    [object presentViewController:loginVC animated:YES completion:nil];
    
}
@end
